<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Cool Cloud</title>

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome Icons -->
    <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
    <!-- IonIcons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/adminlte.min.css">
    <!--文件上传-->
    <link rel="stylesheet" href="dist/css/upload-file.css">
    <!--右键弹出菜单-->
    <link rel="stylesheet" href="dist/js/xcConfirm/css/xcConfirm.css">
    <link rel="stylesheet" href="dist/js/context-menu/css/contextMenu.css">
    <style>
        .tipmsg1,
        .tipmsg {
            background-color: #f39c12;
            position: absolute;
            z-index: 100;
            top: 30px;
            right: 3%;
            padding: 5px 5px 5px 5px;
            border-radius: 15px;
            border: 2px solid #ddd;
            box-shadow: 0 15px 15px -5px rgba(0, 0, 0, 0.2);
            color: white;
        }

        .files-items {
            margin-top: -20px;
            border-bottom: 1px dashed #bdc3c7;
            border-top: 1px dashed #bdc3c7;
        }

        .files-items:hover {
            background: #F4FBFF;
        }
    </style>
</head>
<body class="hold-transition sidebar-mini">
<!-- wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <div th:replace="common/header :: header"></div>

    <!-- Main Sidebar Container -->
    <div th:replace="common/menu :: sidebar"></div>

    <!-- Content Wrapper. Contains page content -->
    <div th:replace="content/uploadContent :: uploadcontent"></div>

    <!-- /Footer -->
    <div th:replace="common/footer :: footer"></div>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark"></aside>
</div>

<!--编辑个人信息-->
<div th:replace="common/editInforModel :: editinfo"></div>

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!--搜索-->
<script src="dist/js/search.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!--上传插件-->
<script src="dist/js/easyUploader.jq.js"></script>
<!--邀请注册-->
<script src="dist/js/invite.js"></script>
<!--搜索-->
<script src="dist/js/search.js"></script>
<script>

    function editMyInfo() {
        $(".userName").val("[[${session.loginUser.userName}]]");
        $(".edit").click();
    }

    function change() {
        let userName = $(".userName").val();
        let IwtNewPsd = $(".IwtNewPsd").val();
        let IwtOralPsd = $(".IwtOralPsd").val();
        let id = [[${session.loginUser.userId}]];
        console.log(userName, id, IwtNewPsd, IwtOralPsd)
        if (userName == '') {
            alert("用户名不能为空！");
            return;
        }
        if ((IwtNewPsd == '' && IwtOralPsd != '') || (IwtNewPsd != '' && IwtOralPsd == '')) {
            alert("需要修改密码,原密码与新密码均不能为空！");
            return;
        }
        var location = window.location.href;
        let string0 = location.split("coolcloud");
        let string1 = location.split("?");
        window.location.href = string0[0] + "coolcloud/UpdateInfoForUploadPage?id=" + id + "&username=" + userName + "&IwtNewPsd=" + IwtNewPsd + "&IwtOralPsd=" + IwtOralPsd + "&" + string1[1];
    }

    if ('' !== $(".tipmsg").text()) {
        setTimeout("closeTip()", 5000);
    }

    function closeTip() {
        var location = window.location.href;
        let string0 = "";
        if (location.lastIndexOf("&") != -1) {
            string0 = location.substring(0, location.lastIndexOf("&"));
        } else {
            string0 = location.substring(0, location.lastIndexOf("?"));
        }
        setTimeout(window.location.href = string0, 5000);
    }

    $(function () {
        $('.folders').dblclick(function () {
            let id = $(this).children("td").children("span").html();
            var location = window.location.href;
            let strings = location.split("?");
            if (id != "") {
                window.location.href = strings[0] + "?fId=" + id;
            } else {
                return;
            }
        });
        $('.folders').hover(function () {
            let id = $(this).children("td").children("span").html();
            $('#tarFolder').html(id);
            $(this).siblings().removeClass('flag');
            $(this).addClass('flag');
        }, function () {
        });
    });
</script>
<!--右键弹出菜单-->
<script src="dist/js/context-menu/js/jquery.contextMenu.min.js"></script>
<script src="dist/js/xcConfirm/js/xcConfirm.js"></script>
<script>
    $(".folders").contextMenu({
        width: 100, // width
        itemHeight: 30, // 菜单项height
        bgColor: "#fff", // 背景颜色
        color: "#333", // 字体颜色
        fontSize: 12, // 字体大小
        hoverBgColor: "#3498db", // hover背景颜色
        target: function (ele) { // 当前元素
            console.log(ele);
        },
        menu: [{ // 菜单项
            text: " 打开",
            callback: function () {
                let id = $('#tarFolder').html();
                var location = window.location.href;
                let strings = location.split("?");
                if (id != "") {
                    window.location.href = strings[0] + "?fId=" + id;
                } else {
                    return;
                }
            }
        },
            {
                text: " 返回上一级",
                callback: function () {
                    toPreFolder();
                }
            }
        ]

    });

    function toPreFolder() {
        var location = window.location.href;
        let strings = location.split("?");
        var pre = $('#preF').html();
        if (pre != "") {
            window.location.href = strings[0] + "?fId=" + pre;
        } else {
            return;
        }
    }
</script>
<!--上传插件-->
<script src="dist/js/easyUploader.jq.js"></script>
<script>
    var uploader = easyUploader({
        id: "uploader",
        accept: '',
        action: 'uploadFile',
        dataFormat: 'formData',
        headers: {
            id: $('#nowF').html()
        },
        maxCount: 10,
        maxSize: 1024,
        multiple: true,
        data: null,
        beforeUpload: function (file, data, args) {
            /* dataFormat为formData时配置发送数据的方式 */
            data.append('token', '387126b0-7b3e-4a2a-86ad-ae5c5edd0ae6TT');
            data.append('otherKey', 'otherValue');

            /* dataFormat为base64时配置发送数据的方式 */
            // data.base = file.base;
            // data.token = '387126b0-7b3e-4a2a-86ad-ae5c5edd0ae6TT';
            // data.otherKey = 'otherValue';
        },
        onChange: function (fileList) {
            /* input选中时触发 */
            document.body.onbeforeunload = function () {
                window.event.returnValue = "确认离开？";
            }
        },
        onRemove: function (removedFiles, files) {
            console.log('onRemove', removedFiles);
        },
        onSuccess: function (res) {
            var code = res["code"];
            console.log(code);
            if (code == 499) {
                alert("可能因为你的违规操作，您暂时无法上传文件！");
            }
            if (code == 501) {
                alert("当前目录存在同名文件，请删除后再试！");
            }
            if (code == 502) {
                alert("文件名不符合规范，支持【汉字,字符,数字,下划线,英文句号,横线】");
            }
            if (code == 503) {
                alert("仓库容量不足，上传失败！");
            }
            if (code == 504) {
                alert("服务器出错了！");
            }
            if (code == 200) {
                $(".tipmsg1").html($('<span  style="margin-right: 25px">  文件上传成功！</span><i class="fas fa-times" onclick="closeTip1()"></i>'));
                $(".tipmsg1").show();
                closeTip2sec();
            }
            document.body.onbeforeunload = function () {
                window.event.returnValue = "确认离开？";
            }
        },
        onError: function (err) {
            console.log('onError', err);
        },
    });

    function closeTip1() {
        $(".tipmsg1").html("");
        $(".tipmsg1").hide();
    }

    function closeTip2sec() {
        setTimeout(function closeTip1() {
            $(".tipmsg1").html("");
            $(".tipmsg1").hide();
        }, 2000);
    }
</script>
</body>
</html>
